package com.zs.usc.demo;

import com.zs.usc.common.RestRst;
import com.zs.usc.common.log.SysMethodLog;
import com.zs.usc.common.log.SysModuleLog;
import com.zs.usc.common.log.enums.LogTypes;
import com.zs.usc.common.log.enums.OperationTypes;
import com.zs.usc.entity.LogInfo;
import com.zs.usc.security.Authorization;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Zero
 * @description 日志测试
 * @date 2022/1/7 17:55
 */
@RestController("logS")
@SysModuleLog(name = "测试日志")
public class LogTest {
    @GetMapping("/get1")
    @SysMethodLog(operationType = OperationTypes.QUERY, logTypes = LogTypes.USER_OPERATION)
    public void test(String uname, String uId) {

        System.out.println(uId + "-" + uname);
    }

    @GetMapping("/get2")
//    @SysMethodLog(operationType = OperationTypes.QUERY, logTypes = LogTypes.USER_OPERATION)
    public void gpogt(@RequestBody LogInfo logInfo) {
            int i = 1 / 0;

            System.out.println("logInfo = " + logInfo);
    }

    @GetMapping("/pot1")
    @SysMethodLog(operationType = OperationTypes.CREATE, logTypes = LogTypes.USER_OPERATION)
    @Authorization
    public RestRst<Void> pot1(@RequestBody LogInfo logInfo) {

        int i = 1 / 0;

        System.out.println(logInfo);
        return RestRst.buildSuccess(null);
    }

    @DeleteMapping("/del1")
    @SysMethodLog(operationType = OperationTypes.DELETE, logTypes = LogTypes.USER_OPERATION)
    public void del1(String id) {

        System.out.println(id);
    }
}
